//
//  IManager+MessageDetail.m
//  RocketProject
//
//  Created by chen jiedan on 13-11-14.
//  Copyright (c) 2013年 Rocket. All rights reserved.
//

#import "IManager+MessageDetail.h"
#import "FrameworkRelativeDefines.h"
#import "RCShopManagerDataModel.h"
#import "NetUrlDefines.h"
#import "RequestUtlity.h"
#import "GloableEngineService.h"
#import "NSString+NSString_Ex_.h"
#import "RCMessageDetailDataModel.h"
#import "RCBaseServerDataModel.h"

@implementation IManager (MessageDetail)

-(int64_t)requestMessageDetailWithUser:(NSString *)readname  withDelegate:(id<IManagerDelegate>)delegate
{
    NSString *bduss = [[GloableEngineService sharedInstance] bduss];
    
    if ([NSString stringIsNullOrEmpty:bduss] || [NSString stringIsNullOrEmpty:readname]) {
        return kInvalidRequestId;
    }
    NSString *urlSuffix = [NSString stringWithFormat:kRCMessageDetailPrefix,bduss,readname];
    
    NSString *url = [RequestUtlity getFormattedUrl:urlSuffix];
    
    KFLog(@"request url %@",url);
    return [[IDataProvider sharedInstance] asyncFetchDataWithUserInfo:url
                                                             userInfo:nil
                                                      withCachePolicy:IDataCachePolicyLocalFileAndNetwork
                                                   withDataParseClass:[RCMessageDetailDataModel class]
                                                     withDataDelegate:delegate];
    
}



-(int64_t)requestToUname:(NSString *)userName withContent:(NSString *)content withDelegate:(id<IManagerDelegate>)delegate
{
    if (nil == userName) {
        return kInvalidRequestId;
    }
    NSString *url = [RequestUtlity getFormattedUrl:kRCMessageSubmitUrlPrefix];
    NSString *bduss = [[GloableEngineService sharedInstance] bduss];
    NSDictionary *postDic = @{@"readname": userName,@"bduss":bduss, @"message":content};
    //    NSDictionary *userInfo =@{@"PostDataValue": postDic};
    //    NSDictionary *userInfo = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObject:@"ServerLoginJson"] forKeys:[NSArray arrayWithObject:@"FakeJson"]];
    
    
    return  [[IDataProvider sharedInstance] asyncPostData:url postValues:postDic postDataList:nil userInfo:nil withDataParseClass:[RCBaseServerDataModel class] withDataDelegate:delegate];
    
}

@end
